<div>

    <czy-toolbar>
        <czy-toolbar-btn>
            <el-button type="primary" icon="plus" size="small" @click="toAdd">新增菜单</el-button>
        </czy-toolbar-btn>
    </czy-toolbar>

    <el-table :data="resData" border stripe highlight-current-row>
        <el-table-tree-column :expand-all="false" :remote="selectSubResource" parentKey="parentId"
                              levelKey="depth" childNumKey="childNum"
                              file-icon="fa fa-file" folder-icon="fa fa-folder"
                              prop="name" label="资源名称" min-width="300">
        </el-table-tree-column>
        <el-table-column prop="code" label="资源编码" min-width="180"></el-table-column>
        <el-table-column prop="url" label="资源标识" min-width="180"></el-table-column>
        <el-table-column prop="types" label="类型" min-width="50" align="center">
            <template scope="scope">
                <el-tag v-if="scope.row.types == 1" type="primary">菜单</el-tag>
                <el-tag v-if="scope.row.types == 2" type="success">目录</el-tag>
                <el-tag v-if="scope.row.types == 3" type="danger">按钮</el-tag>
            </template>
        </el-table-column>
        <el-table-column label="操作" width="140" align="center">
            <template scope="scope">
                <el-tooltip content="新增" placement="top" effect="light">
                    <el-button type="primary" icon="plus" size="mini" @click="toInsert(scope.row)"></el-button>
                </el-tooltip>
                <el-tooltip content="修改" placement="top" effect="light">
                    <el-button size="mini" type="warning" icon="edit" @click="toEdit(scope.row)"></el-button>
                </el-tooltip>
                <el-tooltip content="删除" placement="top" effect="light">
                    <el-button size="mini" type="danger" icon="delete"
                               @click="del(scope.row)"></el-button>
                </el-tooltip>
            </template>
        </el-table-column>
    </el-table>

    <edit @save-success="search" ref="edit"></edit>

</div>